{include file="public/header" /}
<body>
<style>
    .cion{
        display: inline-block;
        width: 120px;
    }
</style>
<div class="page-container">
    <form  method="get" action="">
        <div class="text-c">
            日期范围：
            <input type="text" onfocus="WdatePicker()" value="{:input('get.start')}" name="start" id="datemin" class="input-text Wdate" style="width:120px;" autocomplete="off">
             -
            <input type="text" onfocus="WdatePicker()" value="{:input('get.end')}" name="end" id="datemax" class="input-text Wdate" style="width:120px;" autocomplete="off">
            <input type="text" class="input-text" style="width:250px" placeholder="UID/账号/手机号" value="{:input('word')}" name="word">
            <input type="text" class="input-text" style="width:250px" placeholder="输入上级账号搜索下级" value="{:input('father')}" name="father">
            <span class="select-box" style="width: 100px;">
                <select name="status" class="select">
                    <option value="-1">全部状态</option>
                    <option value="0" {if isset($_GET['status']) && $_GET['status'] == 0}selected{/if}>禁用中</option>
                    <option value="1" {if isset($_GET['status']) && $_GET['status'] == 1}selected{/if}>启用中</option>
                </select>
            </span>
            <span class="select-box" style="width: 100px;">
                <select name="activity" class="select">
                    <option value="-1">激活状态</option>
                    <option value="0" {if isset($_GET['activity']) && $_GET['activity'] == 0}selected{/if}>未激活</option>
                    <option value="1" {if isset($_GET['activity']) && $_GET['activity'] == 1}selected{/if}>已激活</option>
                </select>
            </span>
            <button type="submit" class="btn btn-success">搜索</button>
        </div>
    </form>

    <div class="cl pd-5 bg-1 bk-gray mt-20">
         <span class="l">
            <a href="javascript:;" onclick="layopen('添加用户','{:url('add')}')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i>添加用户</a>
        </span>
        <span class="r">共有数据：<strong>{$list->total()}</strong> 条</span> </div>
    <table class="table table-border table-bordered table-hover table-bg">
        <thead>
            <tr>
                <th scope="col" colspan="9">账户列表</th>
            </tr>
            <tr class="text-c">
                <th width="100">账号</th>
                <th width="70">上级</th>
                <th width="80">注册/更新时间</th>
                <th width="120">金额</th>
                <th width="20">权重</th>
                <th width="40">等级</th>
                <th width="20">实名</th>
                <th width="30">状态操作</th>
                <th width="60">操作</th>
            </tr>
        </thead>
        <tbody>
            {foreach $list as $v}
            <tr class="text-c">

                <td class="text-l">   ID：{$v.id}：  账号：{$v.username} <br>
                  紧急联系人：{$v.nickname}<br>紧急联系人电话：{$v.contact}
                </td>
                <td class="text-l">
                    {if $v.parent_id > 0}
                    id：{$v.parent_id} <br>账号：{$v.parent_name}
                    {/if}
                </td>
                <td>注册时间{$v.created}<br> 修改时间{$v.updated}</td>
                <td class="text-l" >
                    mt可用：{$v.mt}  mt冻结：{$v.mt_forze} <br>
                    奖金：{$v.income}  合约收益：{$v.contract_come}   兑换券：{$v.volume}
                </td>
                <td class="text-l" >
                    {$v.weight}
                </td>
                <td class="text-l" >
                    团队等级：
                    {foreach $levels as $level}
                        {if $level.level == $v.level}
                                {$level.name}
                        {/if}
                    {/foreach}
                    <br>
                    推荐等级：
                    {foreach $child_levels as $level}
                        {if $level.level == $v.child_level}
                            {$level.name}
                        {/if}
                    {/foreach}
                </td>
                <td class="text-l" >
                    {switch name="$v.real_status"}
                    {case value="0"}审核中{/case}
                    {case value="1"}审核通过{/case}
                    {case value="2"}审核拒绝{/case}
                    {default /}未提交
                    {/switch}
                </td>
                <td>
                    {if $v.status == 1}
                        <span class="label label-success radius" onclick="member_start(this,{$v.id},{$v.status})" style="cursor:pointer ">
                        账号已启用</span>
                    {else/}
                        <span class="label label-danger radius" onclick="member_start(this,{$v.id},{$v.status})"  style="cursor:pointer ">
                        账号禁用中</span>
                    {/if}
                    <br>
                    <br>
                    {if $v.activity == 1}
                    <span class="label label-success radius" onclick="member_activity(this,{$v.id},{$v.activity})"  style="cursor:pointer ">
                        账号已激活</span>
                    {else/}
                    <span class="label label-danger radius" onclick="member_activity(this,{$v.id},{$v.activity})"  style="cursor:pointer ">
                        账号未激活</span>
                    {/if}
                </td>
                <td>
                    <a class="btn-link" title="编辑" href="javascript:;" onclick="layopen('编辑','{:url('edit',['id'=>$v.id])}')">编辑</a>
                    <a class="btn-link" title="充值" href="javascript:;" onclick="layopen('充值','{:url('recharge',['id'=>$v.id])}')">充值</a>
                    <br>
                    <a class="btn-link" title="质押中订单" href="javascript:;" onclick="layopen('质押中订单','{:url('usersells',['id'=>$v.id])}',1200,800)">质押</a>
                    <a class="btn-link" title="收款" href="javascript:;" onclick="layopen('收款','{:url('/bank/myBanks',['id'=>$v.id])}',1200,800)">收款</a>
                    <br>
                    <a class="btn-link" title="团队" href="javascript:;" onclick="layopen({$v.username}+'的团队','{:url('tree',['id'=>$v.id])}',1200,800)">团队</a>
                    <a class="btn-link" title="网页" href="javascript:;" onclick="login_web({$v.id})">网页</a>

                </td>
            </tr>
            {/foreach}
        </tbody>
    </table>
    <div class="page">
        {$list->render()|raw}
    </div>
</div>

{include file="public/footer" /}

<script type="text/javascript">
    
    function login_web(id) {
        var info = '确认要登录此用户的网页版么？';
        layer.confirm(info,function(index){
            $.ajax({
                type: 'POST',
                url: "login_web?id="+id,
                data: {id:id},
                dataType: 'json',
                success: function(data){
                    if(data.status == 1){
                        layer.msg("操作成功",{icon:1,time:1000,shade: [0.3, '#000']},function(){
                            window.open(data.url+"?token="+data.data.token+"&json="+data.data.user);
                        });
                    }else{
                        layer.msg(data.msg,{icon:2,time:1000,shade: [0.3, '#000']});
                    }
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        });
    }
function member_start(obj,id,status){
    if(status == 0){
        var info = '确认要启用吗？';
    }else{
        var info = '确认要禁用用户吗？,,禁用此用户将变成未激活用户，且不能登录';
    }
    layer.confirm(info,function(index){
        $.ajax({
            type: 'POST',
            url: "{:url('status')}",
            data: {id:id,status:status},
            dataType: 'json',
            success: function(data){
                if(data.status == 'y'){
                    layer.msg("操作成功",{icon:1,time:1000,shade: [0.3, '#000']},function(){
                        location.replace(location.href);
                    });
                }else{
                    layer.msg(data.info,{icon:2,time:1000,shade: [0.3, '#000']});
                }
            },
            error:function(data) {
                console.log(data.msg);
            },
        });
    });
}
function member_activity(obj,id,status){
    if(status == 0){
        var info = '确认要激活用户吗？';
    }else{
        var info = '确认要设置用户为未激活状态吗，需要去商城购买商品从新激活？';
    }
    layer.confirm(info,function(index){
        $.ajax({
            type: 'POST',
            url: "{:url('userActivity')}",
            data: {id:id,status:status},
            dataType: 'json',
            success: function(data){
                if(data.status == 'y'){
                    layer.msg("操作成功",{icon:1,time:1000,shade: [0.3, '#000']},function(){
                        location.replace(location.href);
                    });
                }else{
                    layer.msg(data.info,{icon:2,time:1000,shade: [0.3, '#000']});
                }
            },
            error:function(data) {
                console.log(data.msg);
            },
        });
    });
}

</script>